package com.china08.yxyapi.config;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import cn.jpush.api.JPushClient;

/**
 * 极光推送
 * 
 * @author Administrator
 *
 */
@Component
public class JpushConfig {

    private static final Logger LOGGER = LoggerFactory.getLogger(JpushConfig.class);

    @Value(value = "${jpush.appKey}")
    private String appKeyEnt;

    @Value(value = "${jpush.masterSecret}")
    private String masterSecretEnt;

    @Value(value = "${jpush.appKey.epack}")
    private String appKeyEnt_EPack;

    @Value(value = "${jpush.masterSecret.epack}")
    private String masterSecretEnt_EPack;

    public JPushClient getInstance() {
        JPushClient ClientEnt = new JPushClient(masterSecretEnt, appKeyEnt);
        LOGGER.info("极光发送key:" + appKeyEnt);
        return ClientEnt;
    }

    public JPushClient getInstance(String flag) {
        JPushClient ClientEnt;
        if (StringUtils.isNotBlank(flag)) {
            ClientEnt = new JPushClient(masterSecretEnt_EPack, appKeyEnt_EPack);
            LOGGER.info("极光发送key:" + appKeyEnt_EPack);
        } else {
            ClientEnt = new JPushClient(masterSecretEnt, appKeyEnt);
            LOGGER.info("极光发送key:" + appKeyEnt);
        }
        return ClientEnt;
    }
}
